package de.jmda.gui.swing.mvc;

/**
 * Base class for component controllers that use the jmda mvc support.
 * <p>
 * Subclasses retrieve {@link ControllerContext} from {@link
 * #controllerContextProvider}.
 *
 *
 */
public abstract class AbstractController<MODEL extends ModelBase>
{
	protected ControllerContextProvider controllerContextProvider;

	protected AbstractController(
			ControllerContextProvider controllerContextProvider)
	{
		this.controllerContextProvider = controllerContextProvider;
	}
	
	/**
	 * Implement this method to enable injection of the component's model instance
	 * into the component's controller.
	 * <p>
	 * Because the component's model instance can be injected into the component's
	 * controller the component does not necessarily have to store the model
	 * instance itself.
	 * <p>
	 * Implementations of this method have to update all parts of the component
	 * appropriately.
	 *
	 * @param model
	 */
	public abstract void setModel(MODEL model);
	
	/**
	 * Implement this method so that it calls {@link
	 * ControllerContextProvider#getControllerContext()} to retrieve up to date
	 * information about the component's status.
	 */
	public abstract void refreshControllerContext();
}